<?php

RegisterPlugin("Rating","ActivePlugin_Rating");

function ActivePlugin_Rating() {
	Add_Filter_Plugin('Filter_Plugin_Zbp_MakeTemplatetags','Rating_Pre');
}

function InstallPlugin_Rating(){
	global $zbp;
	if(!$zbp->Config('Rating')->open_reg){
            $zbp->Config('Rating')->open_reg='79300975@qq.com';
            $zbp->Config('Rating')->tcvip1='亲，博主才刚刚认识你！';
            $zbp->Config('Rating')->tcvip2='亲，这是热心围观群众！';
            $zbp->Config('Rating')->tcvip3='亲，这是资深水王！';
            $zbp->Config('Rating')->tcvip4='亲，这不是QQ啊！';
            $zbp->Config('Rating')->tcvip5='亲，数据库都让你刷爆了';
            $zbp->Config('Rating')->tcvip6='亲，数据库真的不行了';
            $zbp->Config('Rating')->tcvip7='亲，法律已经无法阻挡你回复了。';
            $zbp->SaveConfig('Rating');
	}
}

function Rating_Pre(&$template){
	global $zbp;
	$zbp->header .='<link rel="stylesheet" href="'.$zbp->host.'zb_users/plugin/Rating/style.css" type="text/css" />' . "\r\n";
}

function Rating_get_author_class($comment_author_email){
    global $zbp;
    $comment=$zbp->table['Comment'];
	$adminEmail =$zbp->Config('Rating')->open_reg;
	$author_count ='SELECT comm_Name,COUNT(*) AS alluser FROM '.$comment.' WHERE comm_Email ="'.$comment_author_email.'"';
	$array=$zbp->db->Query($author_count);
	$array=current($array);
	$author_count=GetValueInArray($array,'alluser');

    if($comment_author_email ==$adminEmail) 
        echo '<a class="vp" target="_blank" href="" title="这是博主"></a>';
    if($author_count>=0 && $author_count < 10 && $comment_author_email !==$adminEmail) 
        echo '<a class="vip1" target="_blank" href="" title="'.$zbp->Config('Rating')->tcvip1.'"></a>';
    else if($author_count>=10 && $author_count < 20 && $comment_author_email !==$adminEmail) 
        echo '<a class="vip2" target="_blank" href="" title="'.$zbp->Config('Rating')->tcvip2.'"></a>';
    else if($author_count>=20 && $author_count < 30 && $comment_author_email !==$adminEmail)
        echo '<a class="vip3" target="_blank" href="" title="'.$zbp->Config('Rating')->tcvip3.'"></a>';    
    else if($author_count>=30 && $author_count < 40 && $comment_author_email !==$adminEmail) 
        echo '<a class="vip4" target="_blank" href="" title="'.$zbp->Config('Rating')->tcvip4.'"></a>';    
    else if($author_count>=40 &&$author_count < 50 && $comment_author_email !==$adminEmail) 
        echo '<a class="vip5" target="_blank" href="" title="'.$zbp->Config('Rating')->tcvip5.'"></a>';    
    else if($author_count>=50 && $author_count < 100 && $comment_author_email !==$adminEmail) 
        echo '<a class="vip6" target="_blank" href="" title="'.$zbp->Config('Rating')->tcvip6.'"></a>';    
    else if($author_count>=100 && $comment_author_email !==$adminEmail) 
        echo '<a class="vip7" target="_blank" href="" title="'.$zbp->Config('Rating')->tcvip7.'"></a>';    
}
?>